package com.scs.application.modules.sys.security;

import com.scs.application.modules.sys.entity.User;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class UserPrincipal extends User implements Serializable {

    private List<String> roleCodes;
    private String ipAddrCustom;


    public boolean hasRole(String roleCode) {

        if (roleCodes == null) {
            return false;
        }
        return roleCodes.contains(roleCode);
    }

    public boolean isAdmin() {
        return "admin".equalsIgnoreCase(this.getCode())
                ||
                hasRole("admin")
                ;
    }

    //用户科室ID
    private String deptId;
    //是否是业务科室
    private String deptFlagBus;
    //用户科室类型 0：普通；1：手术室；2手术间；3：介入室；4：有二级库的科室；5：普通病区；
    private String deptBusType;
    //科室名称
    private String deptName;
    //科室是否可以查看所有信息
    private Boolean deptDataAll;

    //是否是项目分支
    private Boolean flagProject;

    private List<String> deptIds; //用户关联科室，多个用,隔开
}
